# Contributor: Julian Weigt <juw@posteo.de>
# Maintainer: Julian Weigt <juw@posteo.de>
pkgname=asymptote
pkgver=2.86
pkgrel=0
pkgdesc="A vector graphics language for technical drawing"
url="https://asymptote.sourceforge.net/"
arch="all !ppc64le !s390x !riscv64" #blocked by texlive
license="GPL-3.0-only"
depends="texlive texlive-dvi ghostscript"
### Optional dependencies
# gsl and gsl-dev for the support of certain special functions.
# fftw for fourier transform of data
# numpy pyqt5 cson and librsvg for GUI program xasy. I could not find cson for alpine though.
# freeglut for openGL support
makedepends="zlib-dev texinfo autoconf bison flex texmf-dist-latexextra"
subpackages="$pkgname-doc"
source="https://downloads.sourceforge.net/sourceforge/asymptote/asymptote-$pkgver.src.tgz
	fix-nullopt-not-declared.patch
	"

prepare() {
	default_prepare
	./autogen.sh
}

build() {
	# Without specifying, the content of texmf goes to /texmf-dist in root dir
	# Build hangs without --disable-gc
	./configure \
		--prefix=/usr \
		--with-latex=/usr/share/texmf/tex/latex \
		--with-context=/usr/share/texmf/tex/context \
		--disable-gc
	make asy

	#-j1 is needed for building documentation with pdflatex due to probably race conditions
	make -j1 all
}

check() {
	### Other option:
	#make check-all. Fails without gsl and gsl-dev.
	make check
}

package() {
	### Other options
	#make install doesn't install html documentation
	make -j1 DESTDIR="$pkgdir" install-all
}

sha512sums="
9e11dbfca10379f07b50dcce0d63c12b793f47741651b1804cf0825e87604c40b5b94acf343ce7f5ca7da83b5ebb0e213090ada80e0b6ebe4f6cec9db67209d6  asymptote-2.86.src.tgz
54bb8b5d71d5ad663da60f4be9b725a9f00cdaf8dd68326a696683269b3bdcb07ba885d6347643c67159a7a38ec7b3196e7c1617fe99d41a4a1a62b135861fce  fix-nullopt-not-declared.patch
"
